package cn.fufeiii.bt.common.util.result;

import cn.fufeiii.bt.common.code.CommonResultEnum;
import cn.fufeiii.bt.common.code.ResultDefinition;

/**
 * 业务异常
 *
 * @author FuFei
 */
public class BizException extends RuntimeException implements ResultDefinition {

    private final Integer code;

    public BizException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public BizException(String message) {
        super(message);
        this.code = CommonResultEnum.SERVER_FAIL.getCode();
    }

    public BizException(ResultDefinition resultDefinition) {
        super(resultDefinition.getMessage());
        this.code = resultDefinition.getCode();
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return super.getMessage();
    }
}
